<?php
/**************************
 * Created on Jan 22, 2011
 * By: Jos Pape
 * info: jospape@hotmail.com
 */
include_once "../../../common.php";
include_once $root."/header.php";
?>
<h1>Potenciele klanten overzicht</h1>
<form action="?" method="post">
	<table>
		<tr>
			<td colspan="3">
				<h2>Zoeken</h2>
			</td>
		</tr>
		<tr>
			<td>
				Naam
			</td>
			<td>:</td>
			<td>
				<input type="text" name="Name" />
			</td>
		</tr>
		<tr>
			<td colspan="3">
				<input type="submit" value=" Zoeken " />
			</td>
		</tr>
	</table>
</form>
<?php

$query = "	SELECT 
				Webshops.*,
				WebshopStatusen.Naam AS Status,
				CONCAT(Users.Firstname, ' ',Users.Lastname) AS Gebruiker,
				WC.Email
			FROM Webshops
				INNER JOIN WebshopStatusen ON WebshopStatusen.ID = Webshops.Status 
				INNER JOIN WebshopContactpersonen AS WC ON WC.WebshopID = Webshops.ID
				LEFT JOIN Users ON Users.ID = Webshops.UserID
			WHERE Webshops.Status = 1 
				AND WC.Email != ''";
if(isset($_POST['Name']) || !empty($_POST['Name']))
	$query .= " AND Webshops.Name LIKE '%".str_replace("'","",$_POST['Name'])."%' ";
	
$query .= " ORDER BY Name ASC";
$result = $_MySQL->runQuery($query);
?>
Er zijn momenteel <?=mysql_num_rows($result);?> Potenciele klanten ingevoerd met Email<br />
<table>
	<thead>
		<tr>
			<th>
				Naam
			</th>
			<th>
				Email
			</th>
			<th>
				URL
			</th>
			<th>
				Datum toegevoegd
			</th>
			<th>
				Gebruiker
			</th>
			<th>
				Status
			</th>
		</tr>
	</thead>
	<tbody>
	<?php
	while($row = mysql_fetch_assoc($result))
	{
		?>
		<tr>
			<td>
				<?=$row['Name'];?>
			</td>
			<td>
				<?=$row['Email'];?>
			</td>
			<td>
				<?=$row['URL'];?>
			</td>
			<td>
				<?=getNiceDateFormat($row['CreateDate'], true);?>
			</td>
			<td>
				<?=$row['Gebruiker'];?>
			</td>
			<td>
				<?=$row['Status'];?>
			</td>
		</tr>
		<?php
	}
	?>
	</tbody>
</table>
<?php

$query = "	SELECT 
				Webshops.*,
				WebshopStatusen.Naam AS Status,
				CONCAT(Users.Firstname, ' ',Users.Lastname) AS Gebruiker,
				WC.Email
			FROM Webshops
				INNER JOIN WebshopStatusen ON WebshopStatusen.ID = Webshops.Status 
				INNER JOIN WebshopContactpersonen AS WC ON WC.WebshopID = Webshops.ID
				LEFT JOIN Users ON Users.ID = Webshops.UserID
			WHERE Webshops.Status = 1 
				AND WC.Email = ''";
if(isset($_POST['Name']) || !empty($_POST['Name']))
	$query .= " AND Webshops.Name LIKE '%".str_replace("'","",$_POST['Name'])."%' ";
	
$query .= " ORDER BY Name ASC";
$result = $_MySQL->runQuery($query);
?>
<br />
<hr />
<br />Er zijn momenteel <?=mysql_num_rows($result);?> Potenciele klanten ingevoerd ZONDER Email<br />
<table>
	<thead>
		<tr>
			<th>
				Naam
			</th>
			<th>
				Email
			</th>
			<th>
				URL
			</th>
			<th>
				Datum toegevoegd
			</th>
			<th>
				Gebruiker
			</th>
			<th>
				Status
			</th>
		</tr>
	</thead>
	<tbody>
	<?php
	while($row = mysql_fetch_assoc($result))
	{
		?>
		<tr>
			<td>
				<?=$row['Name'];?>
			</td>
			<td>
				<?=$row['Email'];?>
			</td>
			<td>
				<?=$row['URL'];?>
			</td>
			<td>
				<?=getNiceDateFormat($row['CreateDate'], true);?>
			</td>
			<td>
				<?=$row['Gebruiker'];?>
			</td>
			<td>
				<?=$row['Status'];?>
			</td>
		</tr>
		<?php
	}
	?>
	</tbody>
</table>
<?php
include_once $root."/footer.php";